﻿namespace Steamworks
{
    using System;
    using System.Collections.Generic;

    public static class SteamEventManager
    {
        private static Dictionary<object, List<object>> listenerCaches = new Dictionary<object, List<object>>();

        public static void ClearListeners(object cacheOwner)
        {
            if (listenerCaches.ContainsKey(cacheOwner))
            {
                listenerCaches[cacheOwner].Clear();
            }
        }

        public static Callback<T> RegisterListener<T>(object cacheOwner, Callback<T>.DispatchDelegate func)
        {
            Callback<T> item = Callback<T>.Create(func);
            if (!listenerCaches.ContainsKey(cacheOwner))
            {
                listenerCaches[cacheOwner] = new List<object>();
            }
            listenerCaches[cacheOwner].Add(item);
            return item;
        }
    }
}

